<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="container-div ui-layout-center">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="user-form">
                <input type="hidden" id="Aid" name="aid">
                <input type="hidden" id="Parentaid" name="parentaid">
                <div class="select-list">
                    <ul>
                        <li>
                            维护ID：<input type="text" name="maid" id="maid"/>
                        </li>

                        <li>
                            联系人：<input type="text" name="linkman"/>
                        </li>

                        <li class="select-time">
                            <label>故障时间：</label><input class="laydate-icon  layer-date"
                                   name="downtime"
                                   id="recivedtime"
                                   value=""
                                   readonly="readonly"
                                   style="width:120px;"
                                   placeholder="开始日期"
                                   title="开始日期"/>
                            <span>-</span>

                            <input class="laydate-icon  layer-date"
                                   name="endtime"
                                   id="endtime"
                                   value=""
                                   readonly="readonly"
                                   style="width:120px;"
                                   placeholder="结束日期"
                                   title="结束日期"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()">
                <i class="fa fa-plus"></i> 添加
            </a>

            <a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="broad:maintain:edit">
                <i class="fa fa-edit"></i> 编辑
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>

<!--这个脚本文件负责显示表格等可视化界面-->
<script th:src="@{/ajax/libs/jquery-layout/jquery.layout-latest.js}"></script>
<script th:inline="javascript">

    var prefix = ctx + "broad/maintainApply";
    var removeFlag = [[${@permission.hasPermi('broad:maintainApply:remove')}]];
    $(function() {
        $('body').layout({ west__size: 185 });
        queryAreaList();
    });

    String.prototype.trim=function(){
        return this.replace(/(^\s*)|(\s*$)/g, "");
    }
    $("#maid").change(function(){
        $(this).val($(this).val().trim());
    });

    function queryAreaList() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            removeUrl: prefix + "/remove",
            detailUrl: prefix + "/detail/{id}",
            updateUrl: prefix + "/edit/{id}",
            exportUrl: prefix + "/export",
            modalName: "申请维护记录",
            search: false,
            showExport: true,
            columns: [
                {
                    checkbox: true
                },
                {
                    field : 'maid',
                    title : '终端序号',
                    sortable: true
                },
                {
                    field : 'teraddress',
                    title : '终端安装地点',
                    sortable: true
                },
                {
                    field : 'linkman',
                    title : '联系人',
                    sortable: true
                },
                {
                    field : 'applicant',
                    title : '申请人',
                    sortable: true
                },
                {
                    field : 'linkphone',
                    title : '联系电话',
                    sortable: true
                },
                {
                    field : 'downtime',
                    title : '故障时间',
                    sortable: true
                },
                {
                    field : 'applytime',
                    title : '提交时间',
                    sortable: true
                },
                {
                    field : 'remark',
                    title : '故障原因',
                    sortable: 'true',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if(value.length > 4)
                        {
                           return (value.slice(0,4) + '...');
                        }else
                            return value;
                    }
                },
                {
                    field : 'status',
                    title : '维护状态',
                    sortable: 'true',
                    formatter: function (value, row, index) {
                        if(value == 1)
                        {
                            return "已维护";
                        }else
                            return "未维护";
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + '" href="#" onclick="$.operate.detail(\'' + row.maid + '\')"><i class="fa fa-edit"></i>详细</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.maid + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                }
                }]
        };
        $.table.init(options);
    }
</script>
<script th:src="@{/js/plugins/layer/laydate/laydate.js}"></script>
<script th:src="@{/js/plugins/layer/layui-v2.4.5/layui/layui.js}"></script>
<script>
    laydate({
        elem:"#recivedtime",
        event:"focus"
    });
    laydate({
        elem:"#recivedtime",
        event:"focus"
    });
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem:"#broad",
            type: 'time',
        });
    });
</script>
<script>
    laydate({
        elem:"#endtime",
        event:"focus"
    });
    laydate({
        elem:"#endtime",
        event:"focus"
    });
    layui.use('laydate', function(){
        var laydate2 = layui.laydate;

        //执行一个laydate实例
        laydate2.render({
            elem:"#broad",
            type: 'time',
        });
    });
</script>
</body>
</html>